﻿using SmartSapce.ServiceLocation;
using SmartSpace.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace SmartSpace.Web
{
    public static class SsSite
    {
        public static string HostUrl { get; private set; }
        public static Application Application { get; set; }

        static SsSite()
        {
            HostUrl = HttpContext.Current.Request.Url.OriginalString.Replace(HttpContext.Current.Request.Url.PathAndQuery, "/");

            ICoreService service = ServiceLocator.Get<ICoreService>();
            Application = service.GetApplication(HostUrl);
        }

        public static void ReLoad()
        {
            HostUrl = HttpContext.Current.Request.Url.OriginalString.Replace(HttpContext.Current.Request.Url.PathAndQuery, "/");

            ICoreService service = ServiceLocator.Get<ICoreService>();
            Application = service.GetApplication(HostUrl);
        }
    }
}
